Fine-Grained Image Similarity

ABSTRACT

Methods, systems, and apparatus, for determining fine-grained image similarity. In one aspect, a method includes training an image embedding function on image triplets by selecting image triplets of first, second and third images; generating, by the image embedding function, a first, second and third representations of the features of the first, second and third images; determining, based on the first representation of features and the second representation of features, a first similarity measure for the first image to the second image; determining, based on the first representation of features and the third representation of features, a second similarity measure for the the first image to the third image; determining, based on the first and second similarity measures, a performance measure of the image embedding function for the image triplet; and adjusting the parameter weights of the image embedding function based on the performance measures for the image triplets.

CLAIM OF PRIORITY

This application claims priority under 35 USC § 119(e) to U.S. PatentApplication Ser. No. 62/015,107, filed on Jun. 20, 2014, the entirecontents of which are hereby incorporated by reference.

BACKGROUND

This specification relates to image processing.

The Internet provides access to a wide variety of resources such asvideo or audio files, web pages for particular subjects, book articles,or news articles. There are many resources available, and to help usersfind resources that may be of interest to them, many companies havedeveloped search systems that identify resources in response to a query.For textual searches, search queries usually are terms and phrases. Forimage searches, such as search of still images and videos, the searchqueries can be images, or terms and phrases, or a combination of images,terms and phrases. A search system ranks the resources in response tothe query and provides search results that link to the identifiedresources. The search results are typically ordered for viewingaccording to the rank.

When searching images, a search system may use a trained model functionto identify images that are similar to a search query image. A varietyof model functions can be used. Many of these trained models areoptimized to identify images that belong to a same category.

SUMMARY

This specification describes technologies relating to image processing,and in particular training an image embedding function to distinguishdifferences and identify similarities between images that belong to asame category.

In general, one innovative aspect of the subject matter described inthis specification can be embodied in methods that include the actionsof iteratively training an image embedding function on image triplets,the embedding function comprising a set of parameter weights thatoperate on an input image to produce as output a representation offeatures of the image, each iteration of the training comprising:selecting image triplets, each image triplet being a combination of afirst image, a second image and a third image, wherein a first pairwiserelevance score that measures a similarity of the first image to thesecond image is greater than a second pairwise relevance score thatmeasures the similarity of the first image to the third image; for eachimage triplet: providing each of the first, second and third images asinput to the image embedding function, generating, by the imageembedding function, a first representation of the features of the firstimage, a second representation of the features of the second image, anda third representation of the features of the third image, determining,based on the first representation of features and the secondrepresentation of features, a first similarity measure that measures asimilarity of the first image to the second image, determining, based onthe first representation of features and the third representation offeatures, a second similarity measure that measures a similarity of thefirst image to the third image, determining, based on the first andsecond similarity measures, a performance measure of the image embeddingfunction for the image triplet; adjusting the parameter weights of theimage embedding function based on the performance measures for the imagetriplets; and performing another iteration of the training until acessation event occurs.

Other embodiments of this aspect include corresponding systems,apparatus, and computer programs, configured to perform the actions ofthe methods, encoded on computer storage devices.

Particular embodiments of the subject matter described in thisspecification can be implemented so as to realize one or more of thefollowing advantages and features. The systems and methods describedbelow learn fine-grained image similarity to distinguish the differencesbetween images belonging to the same category. The resulting imageembedding function can incorporate both semantic and visual similarityfeatures. To do so, a learned image embedding function considers bothwithin-class images and between-class images. Within-class images areimages that belong to the same class, and between-class images areimages that belong to different classes. The system implements asampling method and a training data generation method to generate arobust set of image triplets that include both within-class andbetween-class image sets. The multi-scale network structure can captureeffectively the global visual appearance and image category information.

The incorporation of the semantic information is useful fordistinguishing images from different classes, and the incorporation ofvisual information is useful for distinguishing images from the sameclass. The triplet sampling method makes it possible to provide largeamounts of training data to learn the image embedding function.

The details of one or more embodiments of the subject matter describedin this specification are set forth in the accompanying drawings and thedescription below. Other features, aspects, and advantages of thesubject matter will become apparent from the description, the drawings,and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is block diagram of a network architecture for learning an imageembedding function based on image triplet training data.

FIG. 2 is a table of image triplets.

FIG. 3 is a flow diagram of an example process for learning the imageembedding function based on image triplet training data.

FIG. 4 is a block diagram of a network structure for learning the imageembedding function.

FIG. 5 is a flow diagram of an example process for generating imagetriplet training data.

FIG. 6 is a flow diagram of an example process for generatingcollections of images for multiple classes.

Like reference numbers and designations in the various drawings indicatelike elements.

DETAILED DESCRIPTION Overview

FIG. 1 is block diagram of a system 100 for learning an image embeddingfunction ƒ(.) based on image triplet training data. The system 100 canbe implemented in a data processing apparatus system of one or morenetworked computers.

The system 100 iteratively trains the image embedding function on imagetriplets selected from training images 102. The image embedding functionis based on a set of parameter weights W that operate on an input imageto produce as output a representation of features of the image. Datadefining the image embedding function is stored in model data 104.

Each image triplet is a combination of a first image 112, a second image114 and a third image 116. The first image may be considered a “query”image Q, the second image may be considered a “positive” image P, whilethe third image may be considered a “negative” image N. FIG. 2 is atable 200 of image triplets, with rows 210 that correspond to the queryimage, positive image, and negative image. Each column 220 correspondsto an image triplet T such that

T _(k) ={Q _(k) ,P _(k) N _(k)}

As will be described below, the system 100 uses the triplets to train animage embedding function that can, once trained, distinguishfine-grained image similarity of images within a same class.

Learning the Image Embedding Function

Operation of the system 100 is described with reference to FIG. 3, whichis a flow diagram of an example process 300 for learning the imageembedding function based on image triplet training data. The process 300can be implemented in a data processing apparatus system of one or morenetworked computers.

The process 300 is described in the context of a particular imageembedding function that can determine a similarity of two images basedon a distance metric. Furthermore, one example implementation of theimage embedding function ƒ(.) maps an image into a point in Euclideanspace. However, other image embedding functions that generate otherrepresentations of images based on the image features and classificationcan also be used. Accordingly, any appropriate tunable function that canbe iteratively trained by the process 300 can be used, and thus theimage embedding function need not be the particular example functiondescribed below.

To begin an iteration the process 300 selects image triplets (302). Forexample, the triplet selection layer 110 selects the image triplets. Theimage triplets that are selected include the first, second and thirdimages as described above. A first pairwise relevance score measures asimilarity of the first image to the second image, and a second pairwiserelevance score measures the similarity of the first image to the thirdimage. The images in the triplet are selected such that the first imageis more similar to the second image than it is to the third image. Therelevance score may be expressed as r_(i,j)=r(p_(i), p_(j)), where bothp_(i) and p_(j) belong to the same class.

Generation of image triplets is described with reference to FIG. 5below.

For each triplet, the process 300 provides each of the first, second andthird image as input to the image embedding function (304). For example,as shown in FIG. 1, the triplet selection layer 110 provides the firstimage 112, the second image 114 and the third image 116 to the imageembedding function ƒ(.) to generate instances ƒ(.) 122, f(.) 124 andƒ(.) 126. Each instance uses the same embedding function ƒ(.) butreceives only one of the images in the image triplet as input.

For each triplet, the process 300 generates, by the image embeddingfunction, representations of the visual features of each of the images(306). For example, as shown in FIG. 1, the representations ƒ(Q), ƒ(P),and ƒ(N) are generated. In some implementations, the embedding functiongenerates a mapping of the image in Euclidean space as an outputrepresentation of features. However, other functions generating otherrepresentations can be used.

For each triplet, the process 300 determines a first similarity measurethat measures a similarity of the first image to the second image (308),and a second similarity measure that measures a similarity of the firstimage to the third image (310). For example, the ranking layer 130determines, based on the first representation of features ƒ(Q) and thesecond representation of features ƒ(P), a first similarity measure thatmeasures a similarity of the first image to the second image. Likewise,the ranking layer 130 determines, based on the first representation offeatures ƒ(Q) and the third representation of features ƒ(N), a secondsimilarity measure that measures a similarity of the first image to thethird image.

In the case of the embedding function that maps an image into Euclideanspace, the ranking layer 130 may determine the Euclidean distance as thesimilarity measure, e.g.,

D(ƒ(P),ƒ(Q))=∥ƒ(P)−ƒ(Q)∥₂ ²

Thus, the smaller the distance D, the more fine-grained similarity thereis between the images P and Q (or P and N). Conversely, the larger thedistance D, the less fine-grained similarity there is between the imagesP and Q (or P and N).

Again, other similarity measures can be used, such as different distancetype, or a similarity measurement that is not distance based. Thesimilarity measurement used may depend on the representation that theimage embedding function ƒ(.) generates.

For each triplet, the process 300 determines a performance measure ofthe image embedding function for the image triplet based on the firstand second similarity measures (312). For example, the ranking layer 130may determine a performance measure of the image embedding function forthe image triplet based on the first Euclidean distance and the secondEuclidean distance. When this type of image embedding function is used,the system 100 attempts to learn an image embedding function ƒ(.) thatassigns a smaller distance to more similar image pairs, which can beexpressed as:

D(ƒ(p _(i)),ƒ(p _(i) ⁺))<D(ƒ(p _(i)),ƒ(p _(i) ⁻)),

∀p _(i) ,p _(i) ⁺ ,p _(i) ⁻ such that r(p _(i) ,p _(i) ⁺)>r(p _(i) ,p_(i) ⁻)

Where (p_(i), p_(i) ⁺, p_(i) ⁻) are the respective first, second andthird images of a triplet. Accordingly, the performance of the imageembedding function ƒ(.) is proportional to the fraction of tripletorderings that agrees with the ranking of the model based on theperformance measure.

The performance measure of the triplet may, in some implementations,involve determining a hinge loss based on a difference of the firstEuclidean distance and the second Euclidean distance, e.g.,

l(p _(i) ,p _(i) ⁺ ,p _(i) ⁻)=max{0,g+D(ƒ(p _(i)),ƒ(p _(i) ⁺))−D(ƒ(p_(i)),ƒ(p _(i) ⁻))}

The variable g is a gap parameter that regularizes the gap between thedistance of two image pairs (p_(i), p_(i) ⁺) and (p_(i), p_(i) ⁻). Thehinge loss is a convex approximation to the 0-1 ranking error loss,which measures the image function's violation of the ranking orderspecified in the triplet. Other types of performance measures, dependingon the output of the image embedding function ƒ(.), can also be used.

The process 300 adjusts the parameter weights of the image embeddingfunction based on the performance measures for the image triplets (314).For example, an objective function of performance can be computedaccording to:

$\mspace{76mu} {{\min {\sum\limits_{i}\; \xi_{i}}} + {\lambda {W}_{2}^{2}}}$s.t.:  max {0, g + D(f(p_(i)), f(p_(i)⁺)) − D(f(p_(i)), f(p_(i)⁻))} ≤ ξ_(i)∀p_(i), p_(i)⁺, p_(i)⁻     such  that  r(p_(i), p_(i)⁺) > r(p_(i), p_(i)⁻)

The parameter λ is a regularization parameter that controls the marginof the learned function to improve its generalization. W are theparameters of the embedding function ƒ(.). The constraint above can beconverted to an unconstrained optimization by replacing ζ_(i)=l(p_(i),p_(i) ⁺, p_(i) ⁻).

The process 300 determines if a cessation event has occurred (316). Acessation event is an event that causes the training process to stopperforming further training iterations. For example, a maximum number oftraining iterations being reached may be a cessation event, orsatisfaction of the objective performance function described above maybe a cessation event.

Example Network Architecture

In some implementations, the system of FIG. 1 can be used to train aneural network structure to learn the image embedding function ƒ(.). Theneural network computes the embedding of an image p_(i): ƒ(p)∈R^(d),where d is the dimension of feature embedding.

As described above, the ranking layer 130 evaluates the embeddingfunction's violation of the ranking order. In the case of a neuralnetwork being used to generate the embedding function, the ranking layer130 back-propagates the gradients to lower layers of the network so thatthe lower layers can adjust their parameters to minimize the rankingloss.

FIG. 4 is a block diagram of a network structure 400 for learning theimage embedding function. The network structure implements differentlevels of invariance at different scales. For example, the convolutionneural network 410 may be of the ConvNet architecture that is trained toclassify images into different classes, as described in the paperImagenet Classification With Deep Convolutional Neural Networks, A.Krizhevsky, I. Sutskever, and G. Hinton, NIPS, pages 1106-1114 (2012).The convolution neural network 410 implements multiple convolutionallayers that encode strong invariance and captures the image semantics.In particular, the convolution neural network 410 contains multiplestacked convolutional layers, max-pooling layers, local normalizationlayers and fully-connected layers.

In addition to the convolution neural network 410, one or moreadditional convolutional neural networks are also used. As shown in FIG.4, each additional network has fewer convolution layers than theconvolutional neural network 410. For example, the additionalconvolutional neural networks each respectively employ one convolutionallayer 422 and 432.

With respect to FIG. 4, the convolutional layers 422 and 432 areimplemented in two low-resolution paths that extract low resolutionvisual features. The numbers shown on the top of each flow arrowdescribe the size of the output image or feature. The numbers shown onthe top of an entity box describe the size of the kernels for thecorresponding layer. The numbers shown in FIG. 4 are examples only, andmay vary based on the size of the original image to be processed beforedown sampling, and also may vary based on the kernel size. The pathwaysthat include the two convolutional layers 422 and 432 have lessinvariance than the convolutional network 410 and capture the visualappearance of an image.

In the particular example of FIG. 4, the first convolutional neuralnetwork 410 has a first quantity of convolutional layers, e.g., 8, andis trained to classify images into different classes. The convolutionalneural network 410 may, in some implementations, be pre-trained prior tothe training of the image embedding function ƒ(.). For example, theconvolutional neural network 410 may be pre-trained on a dataset that isselected for the convolutional neural network 410 to learn imagesemantic information. The convolutional neural network 410 is configuredto receive as input an image 402 at a first resolution, e.g., 256×256.Other resolutions can also be used.

Each second convolution neural network 422 and 432 constitutes a pathhaving a second quantity of convolutional layers, e.g., one layer, andis trained to extract low-resolution features at respective secondresolutions that are less than the first resolution. For example,subsamplers 420 and 430 down sample the image 402 at 4:1 and 8:1,respectively, and provide the down sampled images to the convolutionallayers 422 and 432.

Each convolutional layer 422 and 432 receives the down sampled image asinput, convolves it with a set of k learnable kernels, and puts throughthe activation function to generate k feature maps. In someimplementations, the convolutional layers 422 and 432 can each beimplemented as a set of local feature detectors.

The max pooling layers 424 and 434 perform max pooling over a localneighborhood around a pixel. The max pooling involves selecting amaximum of a block that is pooled. The max pooling layers 424 and 434makes the feature maps robust to small translations.

The normalization layers 412 and 440 normalize the outputs of theconvolutional neural networks to a normalized scale so that they may becombined in a combiner 442. In some implementations, the normalizationlayers 412 and 440 normalize the feature maps around a localneighborhood to have unit norm and zero mean. This leads to feature mapsthat are robust to the differences in illumination and contrast. In someimplementations, the combiner 442 implements linear embedding to combinethe normalized outputs.

Triplet Generation

To avoid overfitting of the function ƒ(.), it is desirable to utilize alarge variety of training triplets. However, the number of possibletriplets increases cubically with the number of images available in atraining set. It is thus computationally prohibitive to use all possibletriplets for large data sets. For example, for a training dataset of 12million images, the number of all possible triplets in the dataset isapproximately (1.2×107)³=1.728×10²¹.

Thus, a proper subset of all possible triplets is selected for training.However, when choosing the images in a triplet, the selection process ofthe images should have tendency to choose a triplet such that the firstimage is likely more similar to the second image than it is to the thirdimage, where the relevance score is expressed as r_(i,j)=r(p_(i),p_(j)). Thus, instead uniform sampling images for the triplets, theimages are selected according to likelihoods that are based on pairwiserelevance scores and pairwise relevance totals of the images. As will bedescribed below, the pairwise relevance total for each image isgenerated from the pairwise relevance scores for the image relative toeach other image in a set. This process is described with reference toFIG. 5, which is a flow diagram of an example process 500 for generatingimage triplet training data. The process 500 can be implemented in adata processing apparatus system of one or more networked computers.

The process 500 accesses images collected into respective classes (502).With respect to any particular class, e.g., a category or some othercollection construct, a pair of within-class images are a pair of imagesthat belong to the particular class, and a pair of between-class imagesare an image pair in which one image belongs to the particular class andthe other image belongs to another class. The images collected into theclasses can be provided to the system 100, or, in an alternateimplementation, can be generated as described in the next section.

The following steps 504-510 are done for each class, however, in thedescription that follows, the processing and generation of imagetriplets for only one class is described.

The process 500 determines, for a class, pairwise relevance totals ofimages belonging to the class (504). For example, for a set of images Pthat belong to a class c, the pairwise relevance scores r_(i,j)=r(p_(i),p_(j)) can be determined. Let the total relevance score, which is thepairwise relevance total, for the i^(th) image be:

$r_{i} = {\sum\limits_{{{j:c_{j}} = c_{i}},{j \neq i}}\; r_{i,j}}$

The pairwise relevance total of an image p_(i) reflects how relevant theimage is in terms of its relevance to the other images in the samecategory.

The process 500 selects an image in the class of images as a first imagein the image triplet according to a likelihood that is proportional toits pairwise relevance total (506). In particular, to generate atriplet, the system 100 first samples a first image, or query image,p_(i) from P according to its pairwise relevance total r_(i). Thelikelihood of an image being chosen as a query image is thusproportional to its total relevance score.

The process 500 selects another image in the class of images as a secondimage in the image triplet according to a likelihood based on aselection threshold and a pairwise relevance score that measures asimilarity of the first image to the second image (508). The images thatare selected for the second image, also known as the positive image, areselected from the same category from which the first image was selected.Because it is desirable to have a relatively high relevance measure forthe first and second image of a triplet when compared to a relevancemeasure of the first and third image of the triplet, the system 100should be biased to samples the second images p_(i) ⁺ from images withhigh relevance scores r_(i,i+). Thus, the system determines a likelihoodof choosing a given image as the second image p_(i) ⁺ according to thefollowing probability:

${P\left( p_{i}^{+} \right)} = \frac{\min \left\{ {T_{p},r_{i,{i +}}} \right\}}{Z_{i}}$

The value T_(p) is a threshold parameter for a minimum likelihood, andZ_(i) is a normalization constant that is equal to Σ_(i)+P(p_(i) ⁺) forall the p_(i) ⁺ in the same category as the first image p_(i).

In some implementations, the third image, also known as a negativeimage, may be selected from either an in-class image or from anout-of-class image. The choice between selecting an in-class image or anout-of-class image may be made randomly, or may be made according to anin-class/out-of-class target ratio.

For an in-class selection, the process 500 selects another image in theclass of images as a third image in the image triplet according to alikelihood based on the section threshold and the pairwise relevancescore that measures a similarity of the first image to the third image(510A). Because it is desirable to have a relatively low relevancemeasure for the first and third image of a triplet when compared to arelevance measure of the first and second image of a triplet, the system100 should be biased to samples of the second images p_(i) ⁻ from imagewith low relevance scores r_(i,i−). In some implementations, in-classimages are drawn for the third image with the same distributiondescribed above with reference to the second image of the triplet.

For out-of-class selections, the process 500 selects another image inanother class as a third image in the image triplet (510B). In someimplementations, the out-of-class images are drawing uniformly from allthe images that belong to a different class from the first image p_(i).

In some implementations, the system 100 can require that for each imagetriplet, the first, second and third images are selected such that thedifference resulting from subtracting the second pairwise relevancescore from the first pairwise relevance score meets or exceeds athreshold difference T_(r), e.g.,

r _(i,i+) −r _(i,i−) ≥T _(r) ,∀t _(i)=(p _(i) ,p _(i) ⁺ ,p _(i) ⁻)

Triplets that do not meet this criterion are rejected.

A variety of pairwise relevance functions r(.) can be used to realizethe pairwise relevance scores. In some implementations, the functionr(.) is constrained to be 0 for between-class image pairs. For in-classpairs, the function r(.) in some implementations, may include a weightedlinear combination of multiple features, such as histogram objectgradients (HOG) features, scale invariant feature transforms (SIFT),Laplacian of Gaussian (LoG) blob detection, and the like. Furthermore,if image annotation data are available, the function r(.) may also usefeatures derived from the image annotations. The linear weights may belearned through max-margin linear weight learning using human rateddata. Thus, in some implementations, the function r(.) accounts for bothvisual appearance information and semantic information. However, thefunction r(.) may be expensive to compute, and thus modeling the imageembedding function ƒ(.), which is less expensive to compute, results inresource savings.

Other pairwise relevance functions can also be used, and the pairwiserelevance function need not be constrained to be 0 for between-classimage pairs.

Selection of Training Images

In implementations that utilize the network structure 400 of FIG. 4, thesystem 100 uses two collections of training data to train the imageembedding function ƒ(.). The first, as described above, is a datasetthat is selected for the convolutional neural network 410 to learn imagesemantic information. For example, the data set may contain N images inM categories, where N and M are on the order of 1,000. On exampletraining set is the ImageNet ILSVRC-2012 dataset. Other training setscan also be used.

The second training data set is relevance training data, which is usedfor learning fine-grained visual similarity. In some implementations,the images are collected in a bootstrapping fashion, as described withreference to FIG. 6, which is a flow diagram of an example process 600for generating collections of images for multiple classes. The process600 can be implemented in a data processing apparatus system of one ormore networked computers.

The process 600 selects a set of image search queries (602). Forexample, the triplet selection layer 110 may communicate with a searchsystem 108 and select a set of popular queries. The popular quires maybe filtered to ensure class diversity. For example, queries such as“Lions” and “Lion images” may be collapsed into the canonical query“Lions.” The filtering can be implemented using appropriate processesthat measure query similarity and query equivalence. Alternatively, thetriplet selection layer 110 may have been provided a set of queries froman administrator that specified the set of queries.

The process 600 submits each image search query to an image searchengine and receives in response to the image search query dataidentifying images responsive to the query (604). For example, thetriplet selection layer 110 provides each query to the search system 108and receives from the search system image search results for each query.The search results are ranked according to an order that is indicativeof the relevance of the corresponding image to the query.

The process 600, for each image search query, selects a proper subset ofthe top N ranked images identified as being responsive to the imagesearch query (606). For example, for each query, the top N images in therank order are selected. The value of N is selected to ensure that theremay be a diverse set of triplets selected. For example, N may be in therange of 100 to 200.

The process 600 associates each proper subset of top N ranked images asimages collected into a respective class of images, where the respectiveclass is different for each proper subset (608). Each class maycorrespond to the query for which the images were identified.

The images and their associations with classes are then stored as thetraining images 102. The system 100 may then utilize the process 500 ofFIG. 5 to generate the training triplets.

Additional Implementation Details

Embodiments of the subject matter and the operations described in thisspecification can be implemented in digital electronic circuitry, or incomputer software, firmware, or hardware, including the structuresdisclosed in this specification and their structural equivalents, or incombinations of one or more of them. Embodiments of the subject matterdescribed in this specification can be implemented as one or morecomputer programs, i.e., one or more modules of computer programinstructions, encoded on computer storage medium for execution by, or tocontrol the operation of, data processing apparatus.

A computer storage medium can be, or be included in, a computer-readablestorage device, a computer-readable storage substrate, a random orserial access memory array or device, or a combination of one or more ofthem. Moreover, while a computer storage medium is not a propagatedsignal, a computer storage medium can be a source or destination ofcomputer program instructions encoded in an artificially-generatedpropagated signal.

The operations described in this specification can be implemented asoperations performed by a data processing apparatus on data stored onone or more computer-readable storage devices or received from othersources.

The term “data processing apparatus” encompasses all kinds of apparatus,devices, and machines for processing data, including by way of example aprogrammable processor, a computer, a system on a chip, or multipleones, or combinations, of the foregoing. The apparatus can includespecial purpose logic circuitry, e.g., an FPGA (field programmable gatearray) or an ASIC (application-specific integrated circuit). Theapparatus can also include, in addition to hardware, code that createsan execution environment for the computer program in question, e.g.,code that constitutes processor firmware, a protocol stack, a databasemanagement system, an operating system, a cross-platform runtimeenvironment, a virtual machine, or a combination of one or more of them.The apparatus and execution environment can realize various differentcomputing model infrastructures, such as web services, distributedcomputing and grid computing infrastructures.

A computer program (also known as a program, software, softwareapplication, script, or code) can be written in any form of programminglanguage, including compiled or interpreted languages, declarative orprocedural languages, and it can be deployed in any form, including as astand-alone program or as a module, component, subroutine, object, orother unit suitable for use in a computing environment. A computerprogram may, but need not, correspond to a file in a file system. Aprogram can be stored in a portion of a file that holds other programsor data (e.g., one or more scripts stored in a markup languagedocument), in a single file dedicated to the program in question, or inmultiple coordinated files (e.g., files that store one or more modules,sub-programs, or portions of code). A computer program can be deployedto be executed on one computer or on multiple computers that are locatedat one site or distributed across multiple sites and interconnected by acommunication network.

The processes and logic flows described in this specification can beperformed by one or more programmable processors executing one or morecomputer programs to perform actions by operating on input data andgenerating output. Processors suitable for the execution of a computerprogram include, by way of example, both general and special purposemicroprocessors, and any one or more processors of any kind of digitalcomputer. Generally, a processor will receive instructions and data froma read-only memory or a random access memory or both. The essentialelements of a computer are a processor for performing actions inaccordance with instructions and one or more memory devices for storinginstructions and data. Generally, a computer will also include, or beoperatively coupled to receive data from or transfer data to, or both,one or more mass storage devices for storing data, e.g., magnetic,magneto-optical disks, or optical disks. However, a computer need nothave such devices.

Embodiments of the subject matter described in this specification can beimplemented in a computing system that includes a back-end component,e.g., as a data server, or that includes a middleware component, e.g.,an application server, or that includes a front-end component, e.g., auser computer having a graphical user interface or a Web browser throughwhich a user can interact with an implementation of the subject matterdescribed in this specification, or any combination of one or more suchback-end, middleware, or front-end components. The components of thesystem can be interconnected by any form or medium of digital datacommunication, e.g., a communication network.

The computing system can include users and servers. A user and serverare generally remote from each other and typically interact through acommunication network. The relationship of user and server arises byvirtue of computer programs running on the respective computers andhaving a user-server relationship to each other.

While this specification contains many specific implementation details,these should not be construed as limitations on the scope of what may beclaimed. Certain features that are described in this specification inthe context of separate embodiments can also be implemented incombination in a single embodiment. Conversely, various features thatare described in the context of a single embodiment can also beimplemented in multiple embodiments separately or in any suitablesubcombination. Moreover, although features may be described above asacting in certain combinations and even initially claimed as such, oneor more features from a claimed combination can in some cases be excisedfrom the combination, and the claimed combination may be directed to asubcombination or variation of a subcombination.

Similarly, while operations are depicted in the drawings in a particularorder, this should not be understood as requiring that such operationsbe performed in the particular order shown or in sequential order, orthat all illustrated operations be performed, to achieve desirableresults. In certain circumstances, multitasking and parallel processingmay be advantageous. Moreover, the separation of various systemcomponents in the embodiments described above should not be understoodas requiring such separation in all embodiments, and it should beunderstood that the described program components and systems cangenerally be integrated together in a single software product orpackaged into multiple software products.

Thus, particular embodiments of the subject matter have been described.Other embodiments are within the scope of the following claims. In somecases, the actions recited in the claims can be performed in a differentorder and still achieve desirable results. In addition, the processesdepicted in the accompanying figures do not necessarily require theparticular order shown, or sequential order, to achieve desirableresults. In certain implementations, multitasking and parallelprocessing may be advantageous.

What is claimed is: 1-20. (canceled)
 21. A computer-implemented method,comprising: training an image embedding function to operate on an inputimage to produce as output a representation of features of the inputimage by at least: selecting one or more image triplets, each imagetriplet of the one or more image triplets being a combination of a firstimage, a second image and a third image, wherein a first pairwiserelevance score that measures a similarity of the first image to thesecond image is greater than a second pairwise relevance score thatmeasures the similarity of the first image to the third image; and foran image triplet of the one or more image triplets: providing each ofthe first, second and third images as input to the image embeddingfunction, determining a performance measure of the image embeddingfunction for the image triplet; and adjusting the image embeddingfunction based on the performance measures for the image triplet. 22.The computer-implemented method of claim 21, wherein determining theperformance measure of the image embedding function comprises:generating, by the image embedding function, a first representation offeatures of the first image, a second representation of features of thesecond image, and a third representation of features of the third image;determining, based on the first representation of features and thesecond representation of features, a first similarity measure thatmeasures a similarity of the first image to the second image;determining, based on the first representation of features and the thirdrepresentation of features, a second similarity measure that measures asimilarity of the first image to the third image; and determining theperformance measure of the image embedding function based on the firstand second similarity measures.
 23. The computer-implemented method ofclaim 22, wherein determining the first similarity measure that measuresthe similarity of the first image to the second image comprisesdetermining a first distance measure from the first representation ofthe features of the first image and the second representation offeatures of the second image; and wherein determining the secondsimilarity measure that measures the similarity of the first image tothe third image comprises determining a second distance measure from thefirst representation of the features of the first image and the secondrepresentation of features of the second image.
 24. Thecomputer-implemented method of claim 22, wherein the image embeddingfunction generates a mapping of the image in Euclidean space as theoutput representation of features; wherein determining the firstsimilarity measure that measures the similarity of the first image tothe second image comprises determining a first Euclidean distancebetween the first representation of the features of the first image andthe second representation of features of the second image; and whereindetermining the second similarity measure that measures the similarityof the first image to the third image comprises determining a secondEuclidean distance between the first representation of the features ofthe first image and the third representation of features of the thirdimage.
 25. The computer-implemented method of claim 24, whereindetermining the performance measure of the image embedding function forthe image triplet comprises determining the performance measure based onthe first Euclidean distance and the second Euclidean distance.
 26. Thecomputer-implemented method of claim 25, wherein determining theperformance measure based on the first Euclidean distance and the secondEuclidean distance comprises determining a hinge loss based on adifference of the first Euclidean distance and the second Euclideandistance.
 27. The computer-implemented method of claim 26, whereintraining the image embedding function: determining a summation of thehinge losses for the one or more image triplets; determining whether thesummation of the hinge losses meets a minimization criterion; and afterdetermining that the summation of the hinge losses meets theminimization criterion, ceasing training of the image embeddingfunction.
 28. The computer-implemented method of claim 21, wherein theimage embedding function comprises: a first convolutional neural networkhaving a first quantity of convolutional layers and trained to classifya plurality of images into a plurality of different classes, andconfigured to receive as input an image at a first resolution; a secondconvolution neural network having a second quantity of convolutionallayers and trained to extract low-resolution features of a secondresolution that is less than the first resolution, and configured toreceive as input an image at the second resolution, wherein the secondquantity of convolutional layers is less than the first quantity ofconvolutional layers; and wherein training the image embedding functioncomprises: providing the image at the first resolution to the firstconvolution neural network at the first resolution; down sampling theimage to the second resolution to generate a down sampled image, whereinthe down sampled image is at the second resolution; and providing thedown sampled image to the second convolutional neural network.
 29. Thecomputer-implemented method of claim 28, wherein the image embeddingfunction further comprises: a first normalization layer that normalizesthe output of the first convolutional neural network; a secondnormalization layer that normalizes the output of the secondconvolutional neural network; and a linear embedding layer that combinesthe normalized outputs of the first convolutional neural network and thesecond convolutional neural network.
 30. The computer-implemented methodof claim 21, wherein selecting the one or more image triplets comprises:accessing a plurality of images that are collected into respectiveclasses of images; and for at least a first class of images of therespective classes of images: determining, for each image, a pairwiserelevance total that is based on pairwise relevance scores thatrespectively measure the similarity of the image to a respective otherimage in the first class of images; selecting an image in the firstclass of images as a first image of a first image triplet of the one ormore image triplets according to a likelihood that is proportional toits pairwise relevance total; selecting a first candidate image in thefirst class of images as a second image of the first image tripletaccording to a likelihood based on a selection threshold and a firstpairwise relevance score that measures a similarity of the first imageof the first image triplet to the second image of the first imagetriplet; and selecting a second candidate image in the first class ofimages as a third image of the first image triplet according to alikelihood based on the selection threshold and a second pairwiserelevance score that measures a similarity of the first image of thefirst image triplet to the third image of the first image triplet. 31.The computer-implemented method of claim 30, wherein selecting the firstcandidate image in the first class of images as the second image of thefirst image triplet comprises selecting the first candidate image in thefirst class of images based on a minimum of the selection threshold andthe first pairwise relevance score; and wherein selecting the secondcandidate image in the first class of images as the third image of thefirst image triplet comprises: determining whether the second pairwiserelevance score is relatively low when compared to the first pairwiserelevance score; and after determining that the second pairwiserelevance score is relatively low when compared to the first pairwiserelevance score, selecting the second candidate image as the third imageof the first image triplet.
 32. The computer-implemented method of claim30, further comprising: for a second image triplet of the one or moreimage triplets, selecting an image in a second class of images of therespective classes of images as a third image in the second imagetriplet, wherein the second class of images differs from the first classof images.
 33. The computer-implemented method of claim 30, wherein thefirst, second and third images of the first image triplet are selectedsuch that a difference between the second pairwise relevance score andthe first pairwise relevance score exceeds a threshold difference. 34.The computer-implemented method of claim 30, wherein accessing theplurality of images comprises: selecting an image search query;submitting the image search query to an image search engine; aftersubmitting the image search query, receiving image search query dataidentifying one or more ranked images responsive to the image searchquery to, the one or more ranked images ranked according to an order;selecting a set of top N ranked images of one or more ranked images,where N is an integer greater than zero; and associating the set of topN ranked images with a respective class of images of the respectiveclasses of images.
 35. The computer-implemented method of claim 30,wherein determining, for each image, the pairwise relevance totalcomprises determining, for each image, a pairwise relevance score thatis based on a comparison of histogram object gradients (HOG) featuresand scale invariant feature transforms (SIFT).
 36. A non-transitorycomputer storage medium encoded with a computer program, the computerprogram comprising instructions that, when executed by a data processingapparatus, cause the data processing apparatus to perform operationscomprising: training an image embedding function to operate on an inputimage to produce as output a representation of features of the inputimage by at least: selecting one or more image triplets, each imagetriplet of the one or more image triplets being a combination of a firstimage, a second image and a third image, wherein a first pairwiserelevance score that measures a similarity of the first image to thesecond image is greater than a second pairwise relevance score thatmeasures the similarity of the first image to the third image; for animage triplet of the one or more image triplets: providing each of thefirst, second and third images as input to the image embedding function,determining a performance measure of the image embedding function forthe image triplet; and adjusting the image embedding function based onthe performance measures for the image triplet.
 37. The non-transitorycomputer storage medium of claim 36, wherein determining the performancemeasure of the image embedding function comprises: generating, by theimage embedding function, a first representation of features of thefirst image, a second representation of features of the second image,and a third representation of features of the third image; determining,based on the first representation of features and the secondrepresentation of features, a first similarity measure that measures asimilarity of the first image to the second image; determining, based onthe first representation of features and the third representation offeatures, a second similarity measure that measures a similarity of thefirst image to the third image; and determining the performance measureof the image embedding function based on the first and second similaritymeasures.
 38. A system, comprising: a data processing apparatus; and acomputer storage medium encoded with a computer program, the programcomprising instructions that, when executed by the data processingapparatus, cause the data processing apparatus to perform operationscomprising: training an image embedding function to operate on an inputimage to produce as output a representation of features of the inputimage by at least: selecting one or more image triplets, each imagetriplet of the one or more image triplets being a combination of a firstimage, a second image and a third image, wherein a first pairwiserelevance score that measures a similarity of the first image to thesecond image is greater than a second pairwise relevance score thatmeasures the similarity of the first image to the third image; for animage triplet of the one or more image triplets: providing each of thefirst, second and third images as input to the image embedding function;determining a performance measure of the image embedding function forthe image triplet; and adjusting the image embedding function based onthe performance measures for the image triplet.
 39. The system of claim38, wherein determining the performance measure of the image embeddingfunction comprises: generating, by the image embedding function, a firstrepresentation of features of the first image, a second representationof features of the second image, and a third representation of featuresof the third image; determining, based on the first representation offeatures and the second representation of features, a first similaritymeasure that measures a similarity of the first image to the secondimage; determining, based on the first representation of features andthe third representation of features, a second similarity measure thatmeasures a similarity of the first image to the third image; anddetermining the performance measure of the image embedding functionbased on the first and second similarity measures.
 40. The system ofclaim 39, wherein the image embedding function generates a mapping ofthe image in Euclidean space as the output representation of features;wherein determining the first similarity measure that measures thesimilarity of the first image to the second image comprises determininga first Euclidean distance between the first representation of thefeatures of the first image and the second representation of features ofthe second image; wherein determining the second similarity measure thatmeasures the similarity of the first image to the third image comprisesdetermining a second Euclidean distance between the first representationof the features of the first image and the third representation offeatures of the third image; and wherein determining a performancemeasure of the image embedding function for the image triplet comprisesdetermining the performance measure based on the first Euclideandistance and the second Euclidean distance.